package moodish.comm;



import java.io.Serializable;

//Mensagens enviadas dos clientes para os servidor. 

//classe implementa também a interface serializable que permite que seja enviada através do socket .


/**
 * Messages sent from a clients to the server. A message contains a type (enum), 
 * and the client's nickname (String). 
 * <p>
 * <b>Important:</b> <br>
 * A <i>message</i> refers to an object sent from a client to the server.<br>
 * A <i>Moodish message</i> refers to an object sent from a client to be relayed his or her friends<br>
 * 
 *  <p>
 * The payload varies depending on the message type.
 * 
 * @author alc
 */
public class ServerMessage implements ServerSideMessage , Serializable{
	private static final long serialVersionUID = 5561581704889017675L;
	private Type message_type;
	private String message_payload;
	private String message_sender;

	/**
	 * Messages sent from clients to the server. A message contains a type (enum), 
	 *  
	 * A <i>Moodish message</i> refers to an object sent from a client to his or her friends<br>
	 * 
	 * @param m_sender			the user client that sent the message
	 * @param m_payload			the content of the message	
	 * @param m_type			the type of the message (expect any type)
	 */
	
	public ServerMessage(String m_sender , String m_payload , Type m_type){
		this.message_sender = m_sender;
		this.message_payload = m_payload;
		this.message_type = m_type;
	}

	/**
	 * Gets the type of the message.
	 * 
	 * @return type of the message.
	 */
	@Override
	public Type   getType(){
		return this.message_type;
	}
	/**
	 * Gets the payload of the message.
	 * 
	 * @return payload.
	 */
	@Override
	public String getPayload() {
		return this.message_payload;
	}
	/**
	 * Gets the sender of the message. 
	 * 
	 * @return nickname of the sender.
	 */
	@Override
	public String getClientNickname() {
		return this.message_sender;
	}

}
